<?php

namespace App\Library\Service;

use App\Library\Logic\ShopCategoryLogic;
use App\Library\Logic\ShopProductLogic;
use App\Library\Requests\Category\ShopCategoryActivityTypeRequest;
use Illuminate\Http\JsonResponse;

class ShopCategoryService extends BaseService
{
    public function __construct(ShopCategoryLogic $logic)
    {
        return $this->logic = $logic;
    }

    /**
     *
     * @param ShopCategoryActivityTypeRequest $request
     * @return JsonResponse
     *
     */
    public function activityCategory(ShopCategoryActivityTypeRequest $request): JsonResponse
    {
        $productCategoryTwo = ShopProductLogic::findByActivityType($request);
        return success($this->logic->query()
            ->where('status_delete', 0)
            ->whereIn('category_id', $productCategoryTwo)
            ->orderByDesc('category_id')
            ->get()
        );
    }
}
